<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基础数据类型</title>
</head>

<body>

</body>

<script>
    let num;

    console.log(num)

    if (num) {
        console.log('会不会变执行')
    }


    let num2 = null;

    console.log(typeof num2)

    //浮点,浮点是不精确的
    console.log((0.1 + 0.2) === 0.3)

    //字符转number

    let num3 = '123.065';

    console.log(Number(num3));
    console.log(parseInt(num3));

    console.log(Number(num));//Nan
    console.log(Number(num2));//0

    console.log(Number('a'));//

    //能转成整数按整数处理
    let num4 = 10.0;
    let num5 = 20.0
    console.log((num4 + num5) === 30);

    //number 的上限
    console.log(Number.MAX_VALUE);
    console.log(Number.MIN_VALUE);

    //数值怎么转成字符串
    let num6 = 666;
    console.log(num6 + '');
    console.log(String(num6))

    // boolean
    // if(True){
    //     console.log('大写可以哦！！！')
    // }


    // 字符
    let str1 = '学js';
    console.log(str1.length);
    //charAt
    console.log(str1.charAt(1));
    //split 
    let str2 = 'html,css,java,php,js';
    console.log(str2.split(','));
    //把str3 首字母大写
    let str3 = 'javascript';
    console.log(str3[0].toUpperCase())
    console.log(str3.replace('j', str3[0].toUpperCase()));

    let str4 = str3[0].toUpperCase() + str3.substr(1);
    console.log(str4);
    //对象展开，也可以把字符串分割成数组
    //let arrs =[...str3];
    let arrs = str3.split('');
    console.log(arrs)
    arrs[0] = arrs[0].toUpperCase();
    let str6 = arrs.join('');
    console.log(str6);


    let str7 = 'good good study day day up';
    let str8 = 'study hard';
    let img = 'beauty.png'

    //console.log(str8.substr(6))
    console.log(str8.substr(-5, 3))
    console.log(img.substr(-3, 3))

    //如果任一参数小于 0 或为 NaN，则被当作 0
    console.log(str8.substring(-5))

    let str9 = '要不要来干实施，钱多话少，干到老';

    //查看下 str9 又没实施？
    console.log(str9.indexOf('实施'))
    console.log(str9.indexOf('实施', 8))

    num = 'aa';
    if (Number(num)) {//Nan
        console.log('true 还是 false')
    }

    num = '0';
    if (num) {//0
        console.log('num 为01')
    }

    num =0;
    if (num) {//
        console.log('num 为02')
    }







</script>

</html>